package com.leetcode.algorithm.y22.m07;

import com.leetcode.algorithm.common.ListNode;

/**
 * 83. 删除排序链表中的重复元素
 * 
 * https://leetcode.cn/problems/remove-duplicates-from-sorted-list/
 * 
 * @author jie.deng
 *
 */
class Question0083Solution01 {
	
	public ListNode deleteDuplicates(ListNode head) {
		ListNode sentinel = new ListNode(-1);
		sentinel.next = head;
		ListNode prev = sentinel;
		while (prev.next != null) {
			if (prev.next.val == prev.val) {
				prev.next = prev.next.next;
			} else {
				prev = prev.next;
			}
		}
		return sentinel.next;
	}
    
}